<?php

//新闻
function get_news_list ()
{
    global $db;
    $query = "SELECT * FROM kt_newst";
    return $db->get_results($query);
}

function get_news_piclist ()
{
	global $db;
	$query = "SELECT * FROM kt_newst WHERE news_showtype = 2 ORDER BY createtime DESC";
	return $db->get_results($query);
}

function get_news_pagelist ($page)
{
	global $db;
	$start = ($page-1)*15;
	$query = "SELECT * FROM kt_newst WHERE news_showtype = 1 ORDER BY createtime DESC LIMIT $start, 15";
	return $db->get_results($query);
}

function get_news_count ()
{
	global $db;
	$query = "SELECT count(*) FROM kt_newst WHERE news_showtype = 1";
	$row = $db->get_row($query);
	return intval($row[0]);
}

function get_news_obj ($oid)
{
    global $db;
    $query = "SELECT * FROM kt_newst WHERE oid = $oid";
    return $db->get_row($query);
}

function get_user_list ()
{
	global $db;
	$query = "SELECT * FROM kt_user";
	return $db->get_results($query);
}
function get_user_obj ($oid)
{
	global $db;
	$query = "SELECT * FROM kt_user where oid = $oid";
	return $db->get_row($query);
}
function findUserByName ($name)
{
	global $db;
	$query = "SELECT * FROM kt_user WHERE user_name = '$name'";
	return $db->get_row($query);
}

function get_event_year(){
	global $db;
	$query = "SELECT * FROM kt_glory WHERE type = 2 ORDER BY YEAR ASC";
	return $db->get_results($query);
}

function get_honor_year(){
	global $db;
	$query = "SELECT * FROM kt_glory WHERE type = 1 ORDER BY YEAR ASC";
	return $db->get_results($query);
}


/*------------------------------------------begin glory model---------------------------------*/
function get_glory_list ()
{
    global $db;
    $query = "SELECT * FROM kt_glory WHERE type=1";
    return $db->get_results($query);
}

function get_glory_obj ($oid)
{
    global $db;
    $query = "SELECT * FROM kt_glory WHERE oid = $oid AND type=1";
    return $db->get_row($query);
}

/*------------------------------------------end glory model------------------------------------*/

/*------------------------------------------begin event model----------------------------------*/
function get_event_list ()
{
    global $db;
    $query = "SELECT * FROM kt_glory WHERE type=2";
    return $db->get_results($query);
}

function get_event_obj ($oid)
{
    global $db;
    $query = "SELECT * FROM kt_glory WHERE oid = $oid AND type=2";
    return $db->get_row($query);
}

/*------------------------------------------end event model------------------------------------*/

/*------------------------------------------begin cv model-------------------------------------*/
function get_cv_list(){
    global $db;
    $query ="SELECT * FROM kt_cv";
    return $db->get_results($query);
}

function get_cv_obj($oid){
    global $db;
    $query ="SELECT * FROM kt_cv WHERE oid = $oid";
    return $db->get_row($query);
}

/*------------------------------------------end cv model---------------------------------------*/

/*------------------------------------------begin jd model-------------------------------------*/
function get_jd_list(){
    global $db;
    $query ="SELECT * FROM kt_jd";
    return $db->get_results($query);
}

function get_jd_obj($oid){
    global $db;
    $query="SELECT * FROM kt_jd WHERE oid= $oid";
    return $db->get_row($query);
}
/*------------------------------------------end jd model---------------------------------------*/
